<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>NeuZephyr: nz::nodes::calc::GlobalMaxPoolNode Class Reference</title>
<link rel="icon" href="NZ_logo2.png" type="image/x-icon" />
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="NZ_logo2.png"/></td>
  <td id="projectalign">
   <div id="projectname">NeuZephyr
   </div>
   <div id="projectbrief">Simple DL Framework</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.12.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>nz</b></li><li class="navelem"><a class="el" href="namespacenz_1_1nodes.html">nodes</a></li><li class="navelem"><a class="el" href="namespacenz_1_1nodes_1_1calc.html">calc</a></li><li class="navelem"><a class="el" href="classnz_1_1nodes_1_1calc_1_1_global_max_pool_node.html">GlobalMaxPoolNode</a></li>  </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classnz_1_1nodes_1_1calc_1_1_global_max_pool_node-members.html">List of all members</a>  </div>
  <div class="headertitle"><div class="title">nz::nodes::calc::GlobalMaxPoolNode Class Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Performs global max pooling operation across spatial dimensions of input tensor.  
 <a href="#details">More...</a></p>
<div class="dynheader">
Inheritance diagram for nz::nodes::calc::GlobalMaxPoolNode:</div>
<div class="dyncontent">
<div class="center"><img src="classnz_1_1nodes_1_1calc_1_1_global_max_pool_node__inherit__graph.png" border="0" usemap="#anz_1_1nodes_1_1calc_1_1_global_max_pool_node_inherit__map" alt="Inheritance graph"/></div>
<map name="anz_1_1nodes_1_1calc_1_1_global_max_pool_node_inherit__map" id="anz_1_1nodes_1_1calc_1_1_global_max_pool_node_inherit__map">
<area shape="rect" title="Performs global max pooling operation across spatial dimensions of input tensor." alt="" coords="5,80,186,123"/>
<area shape="rect" href="classnz_1_1nodes_1_1_node.html" title="Base class for nodes in a neural network or computational graph." alt="" coords="37,5,154,32"/>
<area shape="poly" title=" " alt="" coords="98,48,98,80,93,80,93,48"/>
</map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for nz::nodes::calc::GlobalMaxPoolNode:</div>
<div class="dyncontent">
<div class="center"><img src="classnz_1_1nodes_1_1calc_1_1_global_max_pool_node__coll__graph.png" border="0" usemap="#anz_1_1nodes_1_1calc_1_1_global_max_pool_node_coll__map" alt="Collaboration graph"/></div>
<map name="anz_1_1nodes_1_1calc_1_1_global_max_pool_node_coll__map" id="anz_1_1nodes_1_1calc_1_1_global_max_pool_node_coll__map">
<area shape="rect" title="Performs global max pooling operation across spatial dimensions of input tensor." alt="" coords="5,80,186,123"/>
<area shape="rect" href="classnz_1_1nodes_1_1_node.html" title="Base class for nodes in a neural network or computational graph." alt="" coords="37,5,154,32"/>
<area shape="poly" title=" " alt="" coords="98,48,98,80,93,80,93,48"/>
</map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a64613a073db56dbc1526aeb226497a73" id="r_a64613a073db56dbc1526aeb226497a73"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a64613a073db56dbc1526aeb226497a73">GlobalMaxPoolNode</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input)</td></tr>
<tr class="memdesc:a64613a073db56dbc1526aeb226497a73"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs a <a class="el" href="classnz_1_1nodes_1_1calc_1_1_global_max_pool_node.html" title="Performs global max pooling operation across spatial dimensions of input tensor.">GlobalMaxPoolNode</a> object.  <br /></td></tr>
<tr class="separator:a64613a073db56dbc1526aeb226497a73"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae35d13815fe6cb9bb46abe235e9469aa" id="r_ae35d13815fe6cb9bb46abe235e9469aa"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ae35d13815fe6cb9bb46abe235e9469aa">forward</a> () override</td></tr>
<tr class="memdesc:ae35d13815fe6cb9bb46abe235e9469aa"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs the forward pass of the global max - pooling operation.  <br /></td></tr>
<tr class="separator:ae35d13815fe6cb9bb46abe235e9469aa"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2242a5196a07fdedc0a66ef457f57487" id="r_a2242a5196a07fdedc0a66ef457f57487"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a2242a5196a07fdedc0a66ef457f57487">backward</a> () override</td></tr>
<tr class="memdesc:a2242a5196a07fdedc0a66ef457f57487"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs the backward pass of the global max - pooling operation.  <br /></td></tr>
<tr class="separator:a2242a5196a07fdedc0a66ef457f57487"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_methods_classnz_1_1nodes_1_1_node"><td colspan="2" onclick="javascript:dynsection.toggleInherit('pub_methods_classnz_1_1nodes_1_1_node')"><img src="closed.png" alt="-"/>&#160;Public Member Functions inherited from <a class="el" href="classnz_1_1nodes_1_1_node.html">nz::nodes::Node</a></td></tr>
<tr class="memitem:a687ee9c34eb61f8f28caa201ca42696e inherit pub_methods_classnz_1_1nodes_1_1_node" id="r_a687ee9c34eb61f8f28caa201ca42696e"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classnz_1_1nodes_1_1_node.html#a687ee9c34eb61f8f28caa201ca42696e">print</a> (std::ostream &amp;os) const</td></tr>
<tr class="memdesc:a687ee9c34eb61f8f28caa201ca42696e inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="mdescLeft">&#160;</td><td class="mdescRight">Prints the type, data, and gradient of the node.  <br /></td></tr>
<tr class="separator:a687ee9c34eb61f8f28caa201ca42696e inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9b85913e12422bb4ac2fff483427bb47 inherit pub_methods_classnz_1_1nodes_1_1_node" id="r_a9b85913e12422bb4ac2fff483427bb47"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classnz_1_1nodes_1_1_node.html#a9b85913e12422bb4ac2fff483427bb47">dataInject</a> (Tensor::value_type *data, bool grad=false) const</td></tr>
<tr class="memdesc:a9b85913e12422bb4ac2fff483427bb47 inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="mdescLeft">&#160;</td><td class="mdescRight">Injects data into a relevant tensor object, optionally setting its gradient requirement.  <br /></td></tr>
<tr class="separator:a9b85913e12422bb4ac2fff483427bb47 inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a609f1730085dd1d31e0ddcbbae48a065 inherit pub_methods_classnz_1_1nodes_1_1_node" id="r_a609f1730085dd1d31e0ddcbbae48a065"><td class="memTemplParams" colspan="2">template&lt;typename Iterator &gt; </td></tr>
<tr class="memitem:a609f1730085dd1d31e0ddcbbae48a065 inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classnz_1_1nodes_1_1_node.html#a609f1730085dd1d31e0ddcbbae48a065">dataInject</a> (Iterator begin, Iterator end, const bool grad=false) const</td></tr>
<tr class="memdesc:a609f1730085dd1d31e0ddcbbae48a065 inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="mdescLeft">&#160;</td><td class="mdescRight">Injects data from an iterator range into the output tensor of the InputNode, optionally setting its gradient requirement.  <br /></td></tr>
<tr class="separator:a609f1730085dd1d31e0ddcbbae48a065 inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af8b4bab3271df92ca1f0914f7a97b1e8 inherit pub_methods_classnz_1_1nodes_1_1_node" id="r_af8b4bab3271df92ca1f0914f7a97b1e8"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classnz_1_1nodes_1_1_node.html#af8b4bab3271df92ca1f0914f7a97b1e8">dataInject</a> (const std::initializer_list&lt; Tensor::value_type &gt; &amp;data, bool grad=false) const</td></tr>
<tr class="memdesc:af8b4bab3271df92ca1f0914f7a97b1e8 inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="mdescLeft">&#160;</td><td class="mdescRight">Injects data from a std::initializer_list into the output tensor of the <a class="el" href="classnz_1_1nodes_1_1_node.html" title="Base class for nodes in a neural network or computational graph.">Node</a>, optionally setting its gradient requirement.  <br /></td></tr>
<tr class="separator:af8b4bab3271df92ca1f0914f7a97b1e8 inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Performs global max pooling operation across spatial dimensions of input tensor. </p>
<p>This node reduces each channel's spatial dimensions (H, W) to a single maximum value, producing output of shape (N, C, 1, 1). Used to extract the most salient spatial features while maintaining channel-wise information.</p>
<p>Core functionality and characteristics:</p><ul>
<li><b>Global Feature Selection</b>: Captures maximum activation per channel across all spatial positions.</li>
<li><b>Position Tracking</b>: Implicitly records max value locations for gradient routing.</li>
<li><b>Sparse Gradient Flow</b>: Propagates gradients exclusively to original max positions during backward pass.</li>
<li><b>Dimensionality Collapse</b>: Reduces H and W dimensions to 1 while preserving channels.</li>
<li><b>Parameter-Free</b>: No learnable parameters required for operation.</li>
<li><b>CUDA Support</b>: Optimized GPU implementation for both forward and backward passes.</li>
</ul>
<p>Key implementation aspects:</p><ul>
<li><b>Forward Pass</b>: Computes channel-wise maxima using tensor reduction with argmax tracking.</li>
<li><b>Backward Pass</b>: Scatters full output gradient to corresponding max positions in input tensor.</li>
<li><b>Efficient Storage</b>: Requires O(N*C) memory for position indices compared to spatial dimensions.</li>
<li><b>Tie Resolution</b>: Selects first occurrence of maximum value when multiple maxima exist.</li>
</ul>
<p>Typical use cases:</p><ul>
<li>Highlighting strongest activation patterns in feature maps</li>
<li>Final feature aggregation for classification tasks</li>
<li>Networks requiring spatial position invariance</li>
<li>Attention mechanisms focusing on dominant features</li>
</ul>
<p>Critical considerations:</p><ul>
<li><b>Feature Discard</b>: Discards all non-maximal spatial information</li>
<li><b>Gradient Sparsity</b>: Only single position per channel receives gradients</li>
<li><b>Input Requirements</b>: Expects 4D input tensor (N, C, H, W) with H, W &gt; 0</li>
</ul>
<dl class="section warning"><dt>Warning</dt><dd><ul>
<li>Input tensor must have spatial dimensions (H, W) &gt; 1 to be meaningful</li>
<li>Not suitable for tasks requiring spatial relationship preservation</li>
<li>May produce unstable gradients if input contains multiple equal maxima</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>Output tensor shape: (N, C, 1, 1)</li>
<li>Often used as alternative to global average pooling for sharper feature selection</li>
<li>Common in architectures emphasizing dominant visual patterns</li>
</ul>
</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classnz_1_1nodes_1_1calc_1_1_global_avg_pool_node.html" title="Performs global average pooling operation across spatial dimensions of input tensor.">GlobalAvgPoolNode</a> For smoothed spatial feature aggregation </dd>
<dd>
<a class="el" href="classnz_1_1nodes_1_1calc_1_1_max_pooling_node.html" title="Implements max pooling operation for spatial downsampling with feature preservation.">MaxPoolingNode</a> For local window-based max pooling</dd></dl>
<h3><a class="anchor" id="autotoc_md112"></a>
Usage Example:</h3>
<div class="fragment"><div class="line"><span class="comment">// Process batch of 16 samples with 512 channels (7x7 spatial)</span></div>
<div class="line">InputNode input({16, 512, 7, 7}, <span class="keyword">true</span>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Apply global max pooling</span></div>
<div class="line"><a class="code hl_class" href="classnz_1_1nodes_1_1calc_1_1_global_max_pool_node.html">GlobalMaxPoolNode</a> gmp(&amp;input);</div>
<div class="line">gmp.forward();</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Output shape becomes (16, 512, 1, 1)</span></div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;Pooled shape: &quot;</span> &lt;&lt; gmp.output-&gt;shape() &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Backpropagate through max positions</span></div>
<div class="line">gmp.backward();</div>
<div class="ttc" id="aclassnz_1_1nodes_1_1calc_1_1_global_max_pool_node_html"><div class="ttname"><a href="classnz_1_1nodes_1_1calc_1_1_global_max_pool_node.html">nz::nodes::calc::GlobalMaxPoolNode</a></div><div class="ttdoc">Performs global max pooling operation across spatial dimensions of input tensor.</div><div class="ttdef"><b>Definition</b> <a href="_nodes_8cuh_source.html#l04619">Nodes.cuh:4619</a></div></div>
</div><!-- fragment --><dl class="section author"><dt>Author</dt><dd>Mgepahmge (<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2023/10/22 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_nodes_8cuh_source.html#l04619">4619</a> of file <a class="el" href="_nodes_8cuh_source.html">Nodes.cuh</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a64613a073db56dbc1526aeb226497a73" name="a64613a073db56dbc1526aeb226497a73"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a64613a073db56dbc1526aeb226497a73">&#9670;&#160;</a></span>GlobalMaxPoolNode()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">nz::nodes::calc::GlobalMaxPoolNode::GlobalMaxPoolNode </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Constructs a <a class="el" href="classnz_1_1nodes_1_1calc_1_1_global_max_pool_node.html" title="Performs global max pooling operation across spatial dimensions of input tensor.">GlobalMaxPoolNode</a> object. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>A pointer to the input node. This pointer is assumed to be managed externally, and the constructor uses it in a read - only manner (host - to - host).</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None</dd></dl>
<p>This constructor initializes a <a class="el" href="classnz_1_1nodes_1_1calc_1_1_global_max_pool_node.html" title="Performs global max pooling operation across spatial dimensions of input tensor.">GlobalMaxPoolNode</a> object. It first adds the provided input node pointer to the <code>inputs</code> vector. Then, it creates a new shared pointer for the <code>output</code> member. The shape of the output tensor is set to have the same batch size and number of channels as the input tensor's output, but with a height and width of 1. The <code>requiresGrad</code> flag of the output tensor is set to the same value as that of the input tensor's output. Finally, it sets the <code>type</code> member to the string "GlobalMaxPool".</p>
<p>Memory management strategy: The constructor does not allocate memory for the input node. It only stores a pointer to it. The <code>output</code> tensor is created using <code>std::make_shared</code>, which manages its memory automatically. Exception handling mechanism: There is no explicit exception handling in this constructor. If the <code>std::make_shared</code> call fails to allocate memory for the <code>output</code> tensor, it may throw a <code>std::bad_alloc</code> exception.</p>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>If memory allocation for the <code>output</code> tensor fails.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>Ensure that the input node pointer is valid and points to a properly initialized node.</li>
<li>The performance of this constructor is mainly determined by the memory allocation for the <code>output</code> tensor, which has a time complexity of O(1) for the pointer management and O(m) for the tensor data allocation, where m is the number of elements in the output tensor.</li>
</ul>
</dd></dl>
<div class="fragment"><div class="line">```cpp</div>
<div class="line"><a class="code hl_class" href="classnz_1_1nodes_1_1_node.html">Node</a>* inputNode = <span class="keyword">new</span> <a class="code hl_class" href="classnz_1_1nodes_1_1_node.html">Node</a>(...); <span class="comment">// Assume Node is properly initialized</span></div>
<div class="line"><a class="code hl_class" href="classnz_1_1nodes_1_1calc_1_1_global_max_pool_node.html">GlobalMaxPoolNode</a> globalMaxPoolNode(inputNode);</div>
<div class="line">```</div>
<div class="ttc" id="aclassnz_1_1nodes_1_1_node_html"><div class="ttname"><a href="classnz_1_1nodes_1_1_node.html">nz::nodes::Node</a></div><div class="ttdoc">Base class for nodes in a neural network or computational graph.</div><div class="ttdef"><b>Definition</b> <a href="_nodes_8cuh_source.html#l00114">Nodes.cuh:114</a></div></div>
</div><!-- fragment --><dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2024/07/15 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_nodes_8cu_source.html#l00745">745</a> of file <a class="el" href="_nodes_8cu_source.html">Nodes.cu</a>.</p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a2242a5196a07fdedc0a66ef457f57487" name="a2242a5196a07fdedc0a66ef457f57487"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2242a5196a07fdedc0a66ef457f57487">&#9670;&#160;</a></span>backward()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void nz::nodes::calc::GlobalMaxPoolNode::backward </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">override</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Performs the backward pass of the global max - pooling operation. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">None</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None</dd></dl>
<p>This function performs the backward pass of the global max - pooling operation. First, it checks if the output tensor of the input node requires gradient computation. If so, it retrieves the host data and gradients of the output tensor. Then, it iterates over each batch and channel of the input tensor's output. For each combination of batch index <code>i</code> and channel index <code>j</code>, it calculates an index <code>idx</code> and uses the <code>find</code> method to locate the position of the maximum value in the input tensor corresponding to the output value at <code>idx</code>. Finally, it sets the gradient at that position in the input tensor using the <code>setData</code> method.</p>
<p>Memory management strategy: This function does not allocate or deallocate any memory directly. It operates on the existing data and gradient tensors of the input and output. Exception handling mechanism: There is no explicit exception handling in this function. If the <code>hostData</code>, <code>hostGrad</code>, <code>find</code>, or <code>setData</code> methods encounter an error, they may throw an exception depending on their implementation.</p>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">[Exception</td><td>type from hostData, hostGrad, find, or setData] If the <code>hostData</code>, <code>hostGrad</code>, <code>find</code>, or <code>setData</code> methods encounter an error during execution.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>Ensure that the input and output tensors and their gradients are properly initialized before calling this function.</li>
<li>The time complexity of this function is O(b * c), where <code>b</code> is the batch size (<code>inputs[0]-&gt;output-&gt;shape()[0]</code>) and <code>c</code> is the number of channels (<code>inputs[0]-&gt;output-&gt;shape()[1]</code>).</li>
</ul>
</dd></dl>
<div class="fragment"><div class="line">```cpp</div>
<div class="line"><a class="code hl_class" href="classnz_1_1nodes_1_1calc_1_1_global_max_pool_node.html">GlobalMaxPoolNode</a> globalMaxPoolNode(...); <span class="comment">// Assume GlobalMaxPoolNode is properly initialized</span></div>
<div class="line">globalMaxPoolNode.backward();</div>
<div class="line">```</div>
</div><!-- fragment --><dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2024/07/15 </dd></dl>

<p>Implements <a class="el" href="classnz_1_1nodes_1_1_node.html#a0a9ecbaa3d790ba38e8218aca7837fd0">nz::nodes::Node</a>.</p>

<p class="definition">Definition at line <a class="el" href="_nodes_8cu_source.html#l00761">761</a> of file <a class="el" href="_nodes_8cu_source.html">Nodes.cu</a>.</p>

</div>
</div>
<a id="ae35d13815fe6cb9bb46abe235e9469aa" name="ae35d13815fe6cb9bb46abe235e9469aa"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae35d13815fe6cb9bb46abe235e9469aa">&#9670;&#160;</a></span>forward()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void nz::nodes::calc::GlobalMaxPoolNode::forward </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">override</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Performs the forward pass of the global max - pooling operation. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">None</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None</dd></dl>
<p>This function conducts the forward pass of the global max - pooling operation. It iterates over each batch and channel of the input tensor's output. For each combination of batch index <code>i</code> and channel index <code>j</code>, it computes the maximum value in the corresponding slice of the input tensor using the <code>max</code> method. Then, it fills the corresponding position in the output tensor using the <code>fillMatrix</code> method.</p>
<p>Memory management strategy: This function does not allocate or deallocate any memory directly. It operates on the existing data tensors of the input and output. Exception handling mechanism: There is no explicit exception handling in this function. If the <code>max</code> or <code>fillMatrix</code> methods encounter an error, they may throw an exception depending on their implementation.</p>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">[Exception</td><td>type from max or fillMatrix] If the <code>max</code> or <code>fillMatrix</code> methods encounter an error during execution.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>Ensure that the input and output tensors are properly initialized before calling this function.</li>
<li>The time complexity of this function is O(b * c), where <code>b</code> is the batch size (<code>inputs[0]-&gt;output-&gt;shape()[0]</code>) and <code>c</code> is the number of channels (<code>inputs[0]-&gt;output-&gt;shape()[1]</code>).</li>
</ul>
</dd></dl>
<div class="fragment"><div class="line">```cpp</div>
<div class="line"><a class="code hl_class" href="classnz_1_1nodes_1_1calc_1_1_global_max_pool_node.html">GlobalMaxPoolNode</a> globalMaxPoolNode(...); <span class="comment">// Assume GlobalMaxPoolNode is properly initialized</span></div>
<div class="line">globalMaxPoolNode.forward();</div>
<div class="line">```</div>
</div><!-- fragment --><dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2024/07/15 </dd></dl>

<p>Implements <a class="el" href="classnz_1_1nodes_1_1_node.html#a8a828c2e91a4aa2a9ab7b94554e4685b">nz::nodes::Node</a>.</p>

<p class="definition">Definition at line <a class="el" href="_nodes_8cu_source.html#l00753">753</a> of file <a class="el" href="_nodes_8cu_source.html">Nodes.cu</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Users/Mgepahmge/Documents/C Program/NeuZephyr/include/NeuZephyr/<a class="el" href="_nodes_8cuh_source.html">Nodes.cuh</a></li>
<li>D:/Users/Mgepahmge/Documents/C Program/NeuZephyr/src/<a class="el" href="_nodes_8cu_source.html">Nodes.cu</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0
</small></address>
</div><!-- doc-content -->
</body>
</html>
